<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>我的个人信息</title>
    <link rel="stylesheet" href="public/a.css" type="text/css">
    <script type="text/javascript" src="public/jquery-3.2.0.min.js"></script>
</head>
<body>
<div class="box">
    <div style="float: right; margin-right: 10px">
        <label style="margin-right: 10px">您好,<span style="color: #1c11ff"><?php echo $username?></span></label>
        <a href="index.php?c=Usersinfo&a=index&ex=exit">退出系统</a>
    </div>
    <h1>我的个人信息</h1>
    <div class="main1">
        <div class="image">
            <img id="img" alt="我的头像" style="width: 200px;height: 200px;" src="<?php echo "public/".$imgurl;?>">
        </div>
        <div id="upfile" style="display: none">
            <form action="" method="post" enctype="multipart/form-data" >
                <input type="file" name="file" id="file"><br>
                <input type="submit" value="确认提交" id="submit"  name="submit">
            </form>
        </div>
        <div class="button">
            <input type="button" id="change" value="修改">
            <input type="button" id="save" value="保存">
        </div>
    </div>
    <div class="main2">
        <label>
            <span>账号：</span>
            <input id="username"  type="text" readonly value="<?php echo $username;?>">
        </label>
        <label>
            <span>昵称：</span>
            <input id="name" type="text" readonly value="<?php echo $name;?>">
        </label>
        <label>
            <span>个性签名：</span>
            <textarea id="utext" cols="40px" rows="5px" readonly ><?php echo $action;?></textarea>
        </label>
    </div>
</div>
</body>
<script type="text/javascript">
    $("#change").on("click",function(){
        if(confirm("鼠标点击要修改的位置即可！")){
            $("#username").on("click",function () {
                alert("此账号为登录系统唯一账号，不可修改！")
            });
            $("#name").one("click",function () {
                $("#name").removeAttr("readonly");
            });
            $("#utext").one("click",function () {
                $("#utext").removeAttr("readonly");
            });
            $("#img").one("click",function () {
                //alert("点击更换头像！");
                $("#upfile").css('display','block');
            });
        }
    });
    $("#save").on("click",function(){
        if(confirm("确认修改您的个人信息吗？"))
        {
            var username=$("#username").val();
            var name=$("#name").val();
            var action=$("#utext").val();

            $.ajax
            ({
                type: "POST",
                url: "?c=Uchange&a=saveUchange",
                data: {username: username,name: name,action:action},
                dataType: "text",
                success: function (result) {
                    if (result==1)
                    {
                        alert("保存成功！");
                    }else
                    {
                        alert("保存失败！")
                    }
                }
            })
        }
    });
</script>
</html>